<head>
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script language="javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<title>驴行天下</title>
<SCRIPT LANGUAGE="javascript"> 
function adaptive(){
	var wight=document.body.clientWidth;
	var Height=document.body.clientHeight;
	
	document.getElementById("grenzhongxing_biaoti").style.height= (wight/720)*300;
	
	if(wight>350){
		document.getElementById("wz_name").style.marginTop=50;
		document.getElementById("wz_name").style.fontSize=22;
		
		document.getElementById("wz_phone").style.fontSize=18;
		
	}
	
	document.getElementById("body").style.display="";
}
</SCRIPT> 
</head>
<?php 
include 'conn_mysql.php';
session_start();

include_once 'conn_login.php';

//读取用户信息
$phone=$_SESSION['phone'];
$openid=$_SESSION['openid'];

//判断入口，确定查询条件
if(strlen($phone)!=0){
	$sql="SELECT * FROM `ecs_users` WHERE mobile_phone='$phone'";
}
if(strlen($openid)!=0){
	$sql="SELECT * FROM `ecs_users` WHERE openid='$openid'";
}
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
	$openid=$row['openid'];
	$user_name=$row['user_name'];
	$phone=$row['mobile_phone'];
	$wx_touxiang=$row['wx_touxiang'];
	$lvbi=$row['pay_points'];//驴币
	$sex =$row['sex '];//0-保密 1男 2女
}

//更新openid及phone的session  以便以后流程可直接使用  注：用户绑定手机号时 应更新phone的session（将分流的入口，在此合并）
$_SESSION['phone']=$phone;
$_SESSION['openid']=$openid;

if($sex==1){
	$sex="男";
}
if($sex==2){
	$sex="女";
}

if(strlen($phone)<4){
	$phone='未绑定';
}
if(strlen($wx_touxiang)==0){
	$wx_touxiang="picture1/touxiang.png";
}

?>
<?php
$bigtype=$_REQUEST['bigtype'];
if(strlen($bigtype)==0){
	$bigtype=1;
}
if($bigtype==1){
?>
<body style="margin:0;padding:0;display:none;background-color:#EBEFF0;" id="body" onload="adaptive()">
	<div style="max-width:640px;height:0px;background-image:url(picture1/grenzhongxing_biaoti.png);margin-top:-1px;margin-left:-1px;background-color:#EBEFF0;background-repeat:repeat;background-size:cover;padding:0px 0 0 0px;position:relative;" id="grenzhongxing_biaoti">
		<a style="float:left;color:#FEFEFE;font-family:微软雅黑;font-size:18px;margin-left:5%;display:block;margin-top:40px;" id="wz_name"><?php echo $user_name;?></a>
		<a style="clear:left;float:left;color:#FEFEFE;font-family:微软雅黑;font-size:15px;margin-left:5%;" id="wz_phone"><?php echo $phone;?>  ></a>
		
		<img style="float:right;width:60px;height:60px;border-radius:30px;margin-right:7%;margin-top:-30px;" src="<?php echo $wx_touxiang;?>" id="touxiang"></img>
	</div>
	
	<div style="width:100%;height:45px;box-shadow:0px 0px 2px 0px #bbb;background-color:#FEFEFE;margin-top:12px;" onclick="tiaozhuan1();">
		<img style="float:left;width:18px;height:13px;margin:16px 0 0 5%;" src="picture1/tubiao1.png"></img>
		<a style="float:left;color:#595757;font-family:微软雅黑;font-size:18px;margin-left:3%;display:block;margin-top:12px;">我的资料</a>
		<a style="float:right;color:#595757;font-family:微软雅黑;font-size:18px;margin-right:3%;display:block;margin-top:10px;">></a>
	</div>
	<div style="width:100%;height:45px;box-shadow:0px 0px 2px 0px #bbb;background-color:#FEFEFE;margin-top:0px;" onclick="My_lvxing();">
		<img style="float:left;width:18px;height:13px;margin:16px 0 0 5%;" src="picture1/tubiao1.png"></img>
		<a style="float:left;color:#595757;font-family:微软雅黑;font-size:18px;margin-left:3%;display:block;margin-top:12px;">我的旅行</a>
		<a style="float:right;color:#595757;font-family:微软雅黑;font-size:18px;margin-right:3%;display:block;margin-top:10px;">></a>
	</div>
	<div style="width:100%;height:45px;box-shadow:0px 0px 2px 0px #bbb;background-color:#FEFEFE;margin-top:0px;" onclick="">
		<img style="float:left;width:17px;height:20px;margin:12.5px 0 0 5%;" src="picture1/tubiao2.png"></img>
		<a style="float:left;color:#595757;font-family:微软雅黑;font-size:18px;margin-left:3%;display:block;margin-top:12px;">我的驴币</a>
		
		<a style="float:right;color:#595757;font-family:微软雅黑;font-size:18px;margin-right:3%;display:block;margin-top:10px;">></a>
		<a style="float:right;color:#E50011;font-family:微软雅黑;font-size:18px;margin-right:3%;display:block;margin-top:12px;"><?php echo $lvbi;?></a>
	</div>
	
	<input type="button" style="clear:left;width:100%;height:50px;background-color:#ff0000;line-height:50px;color:#FFFFFF;font-family:微软雅黑;font-size:20px;border:0; position:fixed;z-index:998;bottom:0px;text-align:center;-webkit-appearance:none;" value="驴行列表" onclick="lvyou_list();"></input>
</body>
<?php } ?>

<?php if($bigtype==2){?>
<body style="margin:0;padding:0;background-color:#EBEFF0;" id="body">
	<input style="width:100%;height:45px;background-color:#E50011;line-height:45px;color:#FFFFFF;font-family:微软雅黑;font-size:20px;border:0; text-align:center;" value="我的旅行" id="zhuche_shou" onfocus="this.blur()" ></input>
	<img style="width:30px;height:30px;position:absolute;left:10px;top:7.5px;" src="picture1/long_small.png" onclick="window.location.href='http://haining.365jinbi.com/lxtx/mobile/index.php?m=default&c=index&a=index';"></img>
	<div style="width:100%;height:10px;"></div>
	<?php

	//超时1小时的放弃订单
	$now_time=time();
	$date_str=date("Y-m-d H:i:s",($now_time-3600));
	$now_date=date("Y-m-d H:i:s",$now_time);

	$sql="update  main_user set is_zhifu='2',del_time='$now_date' where openid='$openid' and is_zhifu=0 and issuetime<='$date_str'";
	$query = mysql_query($sql);



	//查询该用户的订单
	$sql="select * from main_user where openid='$openid' order by id_self desc ";

	$query = mysql_query($sql);
     
     if($query){
	?>
	<div style="clear:left;float:left;box-shadow:0px 0px 2px 0px #bbb;width:100%;height:45px;background-color:#FEFEFE;margin-top:2px;" >
		<span style="color:#E50011;font-family:微软雅黑;font-size:14px;display:block;margin-top:10px;text-align: center;">
		注意啦:请在60分钟内付款，过期视为自动放弃。</span>	
		
	</div>


	<?php
     }

	while($row = mysql_fetch_array($query)){
		$id_difang=$row['id_difang'];
		$banqi    =$row['banqi'];
		//获取该订单的标题
		$sql1="select * from `lvyou_difang_info` where id='$id_difang'";
		$query1 = mysql_query($sql1);
		while($row1 = mysql_fetch_array($query1)){
			$biaoti=$row1['biaoti'];
		}
		//支付状态
		if($row['is_zhifu']==0){
			$is_zhifu="未支付";
			$color="#E50011";
		}
		if($row['is_zhifu']==1){
			$is_zhifu="已支付";
			$color="#78BC28";
		}
		if($row['is_zhifu']==2){
			$is_zhifu="已取消";
			$color="#9F9FA0";
		}
		//获取年月日
		$time=$row['issuetime'];
		$date=substr($time,0,10);
		
		//拼装班期月日
		$banqi_yueri=cut_str($banqi);
		
		//获取已报道人数
		$num=0;
		$sql2="select * from `main_user` where id_difang='$id_difang' and banqi='$banqi' and TIMESTAMPDIFF(day,issuetime,now())<365 and is_zhifu='1'";
		$query2 = mysql_query($sql2);
		while($row2 = mysql_fetch_array($query2)){
			// $num=$num+1;
			//查询此申请人下的随行人员
			$sql3="SELECT * FROM `fu_user` WHERE id='".$row2['id_self']."'";
			$query3 = mysql_query($sql3);
			$num=$num+mysql_num_rows($query3);
		}
		
		//瓶装订单描述
		$dingdan_miaoshu=$date." 已报".$num."人";
	?>


	<div style="clear:left;float:left;box-shadow:0px 0px 2px 0px #bbb;width:100%;height:70px;background-color:#FEFEFE;margin-top:2px;" onclick="tiaozhuang_dingdan('<?php echo $row['id_self'];?>','<?php echo $row['id_difang'];?>','<?php echo $row['openid'];?>');">
		<a style="float:left;color:#3E3A39;font-family:微软雅黑;font-size:16px;display:block;margin-top:10px;margin-left:4%;">
			<?php 
			if(strlen($banqi_yueri.$biaoti)>30){
				echo cut_biaoti($banqi_yueri.$biaoti,30)."...";
			}else{
				echo $banqi_yueri.$biaoti;
			}
			?>
		</a>	
		<a style="float:right;color:<?php echo $color;?>;font-family:微软雅黑;font-size:16px;display:block;margin-top:22px;margin-right:4%;">
		<?php echo $is_zhifu;?></a>
		<a style="clear:left;clear:right;float:left;color:#AAAAAB;font-family:微软雅黑;font-size:16px;display:block;margin-top:-4px;margin-left:4%;">
		<?php echo $dingdan_miaoshu;?></a>
		
	</div>
	<?php } ?>
</body>
<?php } ?>

<SCRIPT LANGUAGE="javascript"> 
function tiaozhuang_dingdan(id_main,id_difang,openid){
	//跳转到订单页面
	window.location.href='getmessage_all.php?bigtype=19&id_main='+id_main+"&id_difang="+id_difang+"&openid="+openid;
}
function My_lvxing(){
	window.location.href='log_gerenzhongxing1.php?bigtype=2';
}
function tiaozhuan1(){
	window.location.href='log_gerenzhongxing2.php?phone=<?php echo $_REQUEST['phone'];?>';
}
function lvyou_list(){
	//判断用户电话号码是否绑定
	<?php 
	if(strlen($_SESSION['phone'])<4){
		//用户未绑定手机号
	?>
		alert('您尚未绑定手机号，请点击我的资料，绑定手机号！');
	<?php
	}else{
		//跳转到旅游列表
	?>
	window.location.href='lvyou_list.php';
	<?php
	}
	?>
}
</SCRIPT>

<?php
function cut_biaoti($string, $length) {
    preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/", $string, $info);
    for($i=0; $i<count($info[0]); $i++) {
        $wordscut .= $info[0][$i];
        $j = ord($info[0][$i]) > 127 ? $j + 2 : $j + 1;
        if ($j > $length - 3) {
            return $wordscut;
        }
    }
    return join('', $info[0]);
}
function cut_str($str){
	$arr=explode('/',$str);
	$yue=$arr[0];
	$ri = $arr[1];
	
	if(substr($yue,0,1)==0){
		$yue=substr($yue,1,1);
	}
	if(substr($ri,0,1)==0){
		$ri=substr($ri,1,1);
	}

	return $yue."月".$ri."日";
}
?>






